local skel = fk.CreateSkill {
  name = "emo__yanggao",
}

Fk:loadTranslationTable{
  ["emo__yanggao"] = "羊羔",
  [":emo__yanggao"] = "你变成了小羊，使用三张基本牌后，变为原武将。",
  ["@emo__sheep"] = "羊羔",
}

skel:addEffect(fk.CardUseFinished, {
  anim_type = "negative",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:getMark("@emo__sheep") > 0 and data.card.type == Card.TypeBasic
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:removePlayerMark(player, "@emo__sheep")
    if player:getMark("@emo__sheep") > 0 then return end
    local mark = player:getMark("emo__sheep") -- 原武将信息
    room:handleAddLoseSkills(player, "-" .. skel.name, nil, false)
    room:setPlayerMark(player, "emo__sheep", 0)
    if type(mark) ~= "table" then return end
    for _, v in ipairs({"kingdom", "gender", "general", "deputyGeneral"}) do
      if mark[v] then
        room:setPlayerProperty(player, v, mark[v])
      end
    end
    if mark.skills then
      room:handleAddLoseSkills(player, mark.skills)
    end
  end,
})

skel:addEffect(fk.EventAcquireSkill, {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return target == player and data.skill and data.skill.name == skel.name
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local mark = { general = player.general, kingdom = player.kingdom, gender = player.gender }
    if player.deputyGeneral ~= "" then
      mark.deputyGeneral = player.deputyGeneral
    end
    local skills = player:getSkillNameList()
    table.removeOne(skills, skel.name)
    if #skills > 0 then
      mark.skills = skills
      room:handleAddLoseSkills(player, "-"..table.concat(skills, "|-"))
    end
    room:setPlayerProperty(player, "general", "emo__sheep")
    room:setPlayerProperty(player, "deputyGeneral", "")
    room:setPlayerProperty(player, "kingdom", "qun")
    room:setPlayerProperty(player, "gender", General.Male)
    room:setPlayerMark(player, "emo__sheep", mark)
    room:setPlayerMark(player, "@emo__sheep", 3)
  end,
})

return skel
